import Express from "express"
import { addTypeServ, deleteTypeServ, findAllTypeServ, findTypeByPageServ, updateTypeServ } from "../Service/typeServ.js";


export const typeRouter =Express.Router();

typeRouter.post('/',async(req,res)=>{
    const data =await addTypeServ(req.body.typename,req.body.color)
    res.json(data)
})

typeRouter.delete('/:id',async(req,res)=>{
    const data =await deleteTypeServ(req.params.id)
    res.json(data)
})

typeRouter.put('/:id',async(req,res)=>{
    const data =await updateTypeServ(req.params.id,req.body)
    res.json(data)
})

typeRouter.get('/all',async(req,res)=>{
    const data =await findAllTypeServ()
    res.json(data)
})

typeRouter.get('/',async(req,res)=>{
    const {page,size} =req.query;
    const data =await findTypeByPageServ(page,size)
    res.json(data)
})